import express from 'express';
import {
  getAllCategories,
  getCategoryById,
  createCategory,
  updateCategory,
  deleteCategory,
  initializeDefaultCategories
} from '../controllers/categoryController.js';

const router = express.Router();

// GET /api/categories - 获取所有分类
router.get('/', getAllCategories);

// POST /api/categories/init - 初始化默认分类
router.post('/init', initializeDefaultCategories);

// GET /api/categories/:id - 获取单个分类
router.get('/:id', getCategoryById);

// POST /api/categories - 创建新分类
router.post('/', createCategory);

// PUT /api/categories/:id - 更新分类
router.put('/:id', updateCategory);

// DELETE /api/categories/:id - 删除分类
router.delete('/:id', deleteCategory);

export default router;